﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Jzy.BLL.Project;
using Jzy.Model.Project;
using System.Data;
using Jzy.Core.Common.Web;
using Jzy.Core.Common;
using Frame.Lib.Utilities;
using Frame.Lib.Common;
using Frame.Lib.Enums;
using Frame.Lib.Web;

public partial class Project_Task_TabList : PageDetail
{
    private string PrjID
    {
        get
        {
            return StrUtil.DecryptUrl(Request.QueryString["PrjID"]);
        }
    }

    /// <summary>
    /// 解密过的
    /// </summary>
    private string TaskID
    {
        get
        {
            return StrUtil.DecryptUrl(Request.QueryString["TaskID"]);
        }
    }

   
    protected string TabIndex
    {
        get
        {
            if (Request["TabIndex"] == null)
            {
                return "0";
            }
            else
            {
                return Request["TabIndex"];
            }

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        JSUtil.SetDivHeight("content", 70);
        CssFileManager.AddCssFile(CssFile.tab1);
        if (!IsPostBack)
        {
            PrjTaskBO task = new PrjTaskBO(int.Parse(PrjID));
            ProjectBO prj = new ProjectBO();

            lnkPrjName.Text = prj.GetName(PrjID);
            lnkTaskName.Text = task.GetName(TaskID);

            BindList();
        }

        lnkBack.HRef = "List.aspx?PrjID=" + StrUtil.EncryptUrl(PrjID);
    }

    private void BindList()
    {
        List<EnumInfo> list = ConvertUtil.ConvertEnum(typeof(TaskTab));

        foreach (EnumInfo info in list)
        {
            TaskTab tab = (TaskTab)info.ID;
            string paras = "?TaskID=" + StrUtil.EncryptUrl(TaskID) + "&PrjID=" + StrUtil.EncryptUrl(PrjID);
            switch (tab)
            {
                case TaskTab.详细信息:
                    info.Tag = "Detail.aspx" + paras;
                    break;
                case TaskTab.变更历史:
                    info.Tag = "ChangeList.aspx" + paras;
                    break;
                case TaskTab.督办记录:
                    info.Tag = "../Oversee/List.aspx" + paras;
                    break;
                case TaskTab.任务进展:
                    info.Tag = "../Schedule/List.aspx" + paras;
                    break;
                case TaskTab.附件:
                    info.Tag = "../Attach/List.aspx" + paras;
                    break;
            }
        }

        rpt.DataSource = list;
        rpt.DataBind();

        EnumInfo firstTab = list.Where(t => t.ID == int.Parse(TabIndex)).First();
        string script = "setFocus(document.getElementById('lnk_" + firstTab.ID + "'),'" + firstTab.Tag + "');";
        JSUtil.ExcuteJS(script);
    }
}
